//
//  TextFiled+Extension.swift
//  CosClub
//
//  Created by 沙睿 on 2020/3/16.
//  Copyright © 2020 ios. All rights reserved.
//

import Foundation
import UIKit

extension UITextField {
    
    public convenience init (text: String? = nil, placeholder: String? = nil, color: UIColor = UIColor.app.c3a, fontSize: CGFloat, type:FontType = FontType.nomal) {
        
        self.init()
        self.textColor = color
        self.clearButtonMode = .whileEditing
        self.text = text
        
        switch type {
        case .nomal:
            self.font = UIFont.sr_system(fontSize: fontSize)
        case .bold:
            self.font = UIFont.sr_bold(fontSize: fontSize)
        case .number:
            self.font = UIFont.sr_number(fontSize: fontSize)
        }
        
        guard let placeholder = placeholder else {
            return
        }
        
        let attrString = NSAttributedString(string: placeholder, attributes: [NSAttributedString.Key.foregroundColor:UIColor.app.c3b])
        self.attributedPlaceholder = attrString
    }
}

public class RoundMaskTextField: UITextField {
    
    public override func layoutSubviews() {
        super.layoutSubviews()
        self.addRoundMask()
    }
}
